package com.wanchuang.hepos.ui.web.inteface;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.webkit.JavascriptInterface;

import com.wanchuang.architecture.utils.LogUtil;
import com.wanchuang.hepos.ui.web.ui.WebViewActivity;


public class JavaScriptInterface {

    private Handler handler;

    public JavaScriptInterface(Handler handler) {
        this.handler = handler;
    }

    @JavascriptInterface
    public void back() {
        Message message = new Message();
        message.what = WebViewActivity.BACK;
        handler.sendMessage(message);
    }



    @JavascriptInterface
    public void goLogin(){
        LogUtil.e("wang","goLogin");
        Message message = new Message();
        message.what = WebViewActivity.LOGIN;
        handler.sendMessage(message);
    }


    @JavascriptInterface
    public void goScanCode(){
        LogUtil.e("wang","goScanCode");
        Message message = new Message();
        message.what = WebViewActivity.SCANNER;
        handler.sendMessage(message);
    }





    @JavascriptInterface
    public void goToMain(){
        LogUtil.e("wang","goToMain");
        Message message = new Message();
        message.what = WebViewActivity.GOTOMAIN;
        handler.sendMessage(message);
    }

    @JavascriptInterface
    public void logout() {
        LogUtil.e("Wang","logout");
        Message message = new Message();
        message.what = WebViewActivity.LOGINOUT;
        handler.sendMessage(message);
    }




    @JavascriptInterface
    public void goToCapture(){
        Log.e("mango", "goToCapture: ");
        Message message = new Message();
        message.what = WebViewActivity.GOTOCAPTURE;
        handler.sendMessage(message);
    }


    @JavascriptInterface
    public void automaticBank(String params) {
        Message message = new Message();
        message.what = WebViewActivity.AUTOBANK;
        message.obj = params;
        handler.sendMessage(message);
    }




    @JavascriptInterface
    public void uploadImg(String methodName) {
        Message message = new Message();
        message.what = WebViewActivity.TAKEPHOTO;
        message.obj = methodName;
        handler.sendMessage(message);
    }


}